import {
  createApp,
  reactive,
  onMounted,
  onUnmounted,
} from "../node_modules/vue/dist/vue.esm-browser.js";
function useMousePosition() {
  const position = reactive({
    x: 0,
    y: 0,
  });
  const update = (e) => {
    position.x = e.pageX;
    position.y = e.pageY;
  };
  onMounted(() => {
    window.addEventListener("mousemove", update);
  });
  onUnmounted(() => {
    window.addEventListener("mousemove", update);
  });
  return position;
}
const app = createApp({
  setup() {
    const position = useMousePosition();
    return {
      position,
    };
  },
  mounted() {
    this.position.x = 200;
  },
});
app.mount("#app");
